<!DOCTYPE html>
<html lang='en'>

<head>
  <meta charset='UTF-8'>
  <meta name='viewport' content='width=device-width, initial-scale=1.0'>
  <title></title>
  <script type='text/javascript' src='js/vue.js'></script>
</head>

<body>
  <div id='app'>
    <input type="button" value="浪起来" @click="run">
    <input type="button" value="停下来" @click="stop">
    <div>{{ msg }}</div>
  </div>
  <script type='text/javascript'>
    var vm = new Vue({
      el: '#app',
      data: {
        flag: [],
        msg: '上海自来水来自海上'
      },
      methods: {
        run() {
          this.flag.push(
            setInterval(() => {
              let arr = this.msg.split('')
              arr.push(arr.shift())
              this.msg = arr.join('')
            }, 150)
          )
        },
        stop() {
          clearInterval(this.flag.pop());
        }
      },
    });
  </script>
</body>

</html>